from flask_restful import Resource

from restful.api__.session import login_required_current_user_generate, pid_required_target_post_generate
from restful.model.query import QueryOneInstance
from restful.model.tables import User, Like
from restful.response import ResponseSuccess


class UserAlreadyLike(Resource):
    @login_required_current_user_generate
    @pid_required_target_post_generate
    def get(self,current_user,target_post):
        like = QueryOneInstance(Like,{'uid':current_user.id,'pid': target_post.id})

        return ResponseSuccess(data={
            'already_like':bool(like)
        })